package jch.learn.java.advanced.chapter4_network.halfClose;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class TestHalfCloseClient {

    public static void main(String[] args) throws IOException {
        try (Socket socket = new Socket("127.0.0.1", 8189)) {
            Scanner in = new Scanner(socket.getInputStream(), StandardCharsets.UTF_8.name());
            PrintWriter writer = new PrintWriter(socket.getOutputStream());
            writer.println("张三");
            writer.flush();
            socket.shutdownOutput();
            while (in.hasNextLine()) {
                String line = in.nextLine();
                System.out.println("Client Receive Msg: ");
                System.out.println(line);
            }
        }
    }

}
